using System;
using UnityEngine;


/// <summary>
/// 
/// </summary>
public class ABLoader : MonoBehaviour
{
    
    void Start()
    {


        string path = $"{Application.streamingAssetsPath}/cube";

        AssetBundle thisAB = AssetBundle.LoadFromFile(path);


        // 加载依赖
        AssetBundle thisABDep = AssetBundle.LoadFromFile($"{Application.streamingAssetsPath}/StreamingAssets");
        var manifest = thisABDep.LoadAsset<AssetBundleManifest>("AssetBundleManifest");
        string[] dependcies = manifest.GetAllDependencies("cube");
        Debug.Log($"{dependcies.Length}");
        Array.ForEach(dependcies, e => AssetBundle.LoadFromFile($"{Application.streamingAssetsPath}/{e}"));

        // 加载模型
        var assetGameObject = thisAB.LoadAsset<GameObject>("cube");
        MonoBehaviour.Instantiate(assetGameObject);


        thisAB.Unload(true);
    }
}
